import server from './server'
import config from '../config';

const BaseUrl = config.apiURL

class API{

    config = {
        ...config.pageData
    }

    async login(data) {
        return await server.post(`${BaseUrl}/api/cmsApi/Login`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async updatePassword(data) {
        return await server.post(`${BaseUrl}/api/cmsApi/UpdatePassword`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchCmsUserList (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/CmsUserPages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async editCmsUser (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/AddCmsUser`, data).then(result => new Promise(resolve => resolve(result)));
    }


    async fetchUserPages (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/GetAuthUserPages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchUpateCmsUser (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/UpateCmsUser`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchUserList (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/GetUserList`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async editInternalUser (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/AddInternalUser`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchRoles (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/GetRoleList`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async editRole (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/AddRole`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async delRole (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/DeleteRole`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchPermissions (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/GetPermissionList`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async addPermission (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/AddPermission`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async editPermission (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/UpdatePermission`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async delPermission (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/DeletePermission`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchRolePermission (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/GetRolePermission`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async getRolePermissionByRoleId (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/GetRolePermissionByRoleId`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async getRolePermissionByUserId (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/GetRolePermissionByUserId`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async editRolePermission (data) {
        return await server.post(`${BaseUrl}/api/cmsApi/UpdateRolePermission`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchMainRudder (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/GetMainRudder`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchRudderPages (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/GetRudderPages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async addRudder (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/AddRudder`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async editRudder (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/UpdateRudder`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async delRudder (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/DeleteRudder`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchGetNetworkPage (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetNetworkPage`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchRudderAppPages (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/GetRudderAppPages`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async addRudderApp (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/AddRudderApp`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async editRudderApp (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/UpdateRudderApp`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async delRudderApp (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/DeleteRudderApp`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async fetchHallSallPages (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetHallMonthGroupBuying`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async fetchHallPages (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/GetHallPages`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async fetchHallList (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/GetHall`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async addHall (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/AddHall`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async editHall (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/UpdateHall`, data).then(result => new Promise(resolve => resolve(result)));
    }
    
    async delHall (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/DeleteHall`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchGoodPages (data) {
        return await server.post(`${BaseUrl}/api/mainGoodsBankApi/MainGoodsPages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async addGoods (data) {
        return await server.post(`${BaseUrl}/api/mainGoodsBankApi/addMainGoods`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async editGood (data) {
        return await server.post(`${BaseUrl}/api/mainGoodsBankApi/UpdateMainGoodsBank`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async delGood (data) {
        return await server.post(`${BaseUrl}/api/mainGoodsBankApi/DeleteMainGoodsById`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async AddPayPosHall (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/AddPayPosHall`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async AddArticleLabel (data) {
        return await server.post(`${BaseUrl}/api/systemapi/AddArticleLabel`, data).then(result => new Promise(resolve => resolve(result)));
    }
    // fetch Hall list
    async fetchHallList (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/GetHall`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async getPayPosHallPages (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/GetPayPosHallPages`, data).then(result => new Promise(resolve => resolve(result)));
    }
   
    async delHall (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/DeleteHall`, data).then(result => new Promise(resolve => resolve(result)));
    }


    async fetchArticlePages (data) {
        return await server.post(`${BaseUrl}/api/articleApi/GetArticlePageList`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async getArticleDetail (data) {
        return await server.post(`${BaseUrl}/api/articleApi/GetArticleDetail`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async addArticle (data) {
        return await server.post(`${BaseUrl}/api/articleApi/AddArticle`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async editArticle (data) {
        return await server.post(`${BaseUrl}/api/articleApi/UpdateArticle`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async delArticle (data) {
        return await server.post(`${BaseUrl}/api/articleApi/DeleteArticle`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchArticleLabelList (data) {
        return await server.post(`${BaseUrl}/api/systemapi/GetArticleLabelList`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async getAnalyRudderMonth (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetAnalyRudderMonth`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async getRudderMonth (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetRudderMonth`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async getMonthGroupBuying (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetMonthGroupBuying`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async getRudderMonthDataExcel (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetRudderMonthDataExcel`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async getRudderNetworkPage (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetRudderNetworkPage`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async getYesterdayData (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetYesterdayData`, data).then(result => new Promise(resolve => resolve(result)));
    }


    async getAnalyArticlePages (data) {
        return await server.post(`${BaseUrl}/api/articleApi/GetAnalyArticlePages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async deleteArticle (data) {
        return await server.post(`${BaseUrl}/api/articleApi/DeleteArticle`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async shelfArticle (data) {
        return await server.post(`${BaseUrl}/api/articleApi/ShelfArticle`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async getArticleSharePages (data) {
        return await server.post(`${BaseUrl}/api/articleApi/GetArticleSharePages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async fetchMessageTemplatePages (data) {
        return await server.post(`${BaseUrl}/api/systemapi/MessageTemplatePages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async addMessageTemplate (data) {
        return await server.post(`${BaseUrl}/api/systemapi/AddMessageTemplate`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async deleteMessageTemplate (data) {
        return await server.post(`${BaseUrl}/api/systemapi/DeleteMessageTemplate`, data).then(result => new Promise(resolve => resolve(result)));
    }



    async rankAnotherNamePages (data) {
        return await server.post(`${BaseUrl}/api/systemapi/RankAnotherNamePages`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async deleteRankAnotherName (data) {
        return await server.post(`${BaseUrl}/api/systemapi/DeleteRankAnotherName`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async addRankAnotherName (data) {
        return await server.post(`${BaseUrl}/api/systemapi/AddRankAnotherName`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async AddRudderRankAnotherName (data) {
        return await server.post(`${BaseUrl}/api/systemapi/AddRudderRankAnotherName`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async RudderRankAnotherNamePages (data) {
        return await server.post(`${BaseUrl}/api/systemapi/RudderRankAnotherNamePages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async RudderGetHallInfo (data) {
        return await server.post(`${BaseUrl}/api/analyRudderApi/GetHallInfo`, data).then(result => new Promise(resolve => resolve(result)));
    }
    
    async GetHallAuditApplyPages (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/GetHallAuditApplyPages`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async AuditHallApply (data) {
        return await server.post(`${BaseUrl}/api/OrganizationApi/AuditHallApply`, data).then(result => new Promise(resolve => resolve(result)));
    }
    async GetArticleCategoryList (data) {
        return await server.post(`${BaseUrl}/api/systemApi/GetArticleCategoryList`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async RedeemCodeapi (data) {
        return await server.post(`${BaseUrl}/api/RedeemCodeapi/Pages?Page=${data.Page}&PageSize=10`).then(result => new Promise(resolve => resolve(result)));
    }

    async AnalyHallUserLabelPage (data) {
        return await server.post(`${BaseUrl}/api/Labelapi/AnalyHallUserLabelPage`, data).then(result => new Promise(resolve => resolve(result)));
    }

    async AnalyUserLabelPage (data) {
        return await server.post(`${BaseUrl}/api/Labelapi/AnalyUserLabelPage`, data).then(result => new Promise(resolve => resolve(result)));
    }

}

export default new API()
